package set集合;

import java.util.HashSet;
import java.util.Set;

public class set集合去重 {
    public static void main(String[] args) {
        Set<student> students=new HashSet<>();
        student a=new student("朱佳铖",18,'男');
        student b=new student("朱佳铖",18,'男');
        student c=new student("李佳辉",180,'女');
        System.out.println(a.hashCode());//-730553992
        System.out.println(b.hashCode());//-730553992重写hashcode和equals之后内容相同的对象的哈希值一样
        System.out.println(c.hashCode());//-705078046
        students.add(a);
        students.add(b);
        students.add(c);
        System.out.println(students);//[student{name='李佳辉', age=180, gender=女}, student{name='朱佳铖', age=18, gender=男}]

    }
}
